import 'package:demo1223/service/service_method.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provide/provide.dart';
import '../provide/conter.dart';

class Memberpage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print("设备的高：${ScreenUtil.screenHeight}");
    print("设备的宽：${ScreenUtil.screenWidth}");
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        backgroundColor: Color.fromRGBO(68, 72, 248, 1),
        actions: <Widget>[
          Container(
            width: ScreenUtil().setWidth(80),
            margin: EdgeInsets.only(right: 30),
            child: InkWell(
              onTap: () {},
              child: Icon(Icons.settings),
            ),
          )
        ],
      ),
      body: FutureBuilder(
        future: DioUtil.request('user'),
        builder: (context, snapshot) {
          print(snapshot.data);
          print('ssssssssssssssssssssssssssssssssssssssssssssssssssssss');
          if (snapshot.hasData) {
            String url = snapshot.data['avatar'];
            String name = snapshot.data['corporate_name'];
            String phone = snapshot.data['phone'];
            return Container(
              color: Colors.grey,
              width: ScreenUtil().setWidth(750),
              child: ListView(
                children: <Widget>[
                  userIn(url, name, phone),
                  money(),
                  userorder(),
                  core()
                ],
              ),
            );
          } else {
            return Text('没有内容');
          }
        },
      ),
    );
  }

  Widget userIn(url, name, phone) {
    return Container(
      child: Stack(
        children: <Widget>[
          Container(
            child: Image.asset('image/userhead.png'),
          ),
          Positioned(
            left: 40,
            top: 24,
            child: Image.network(
              url,
              width: ScreenUtil().setWidth(130),
              height: ScreenUtil().setHeight(130),
            ),
          ),
          Positioned(
            left: 123,
            top: 24,
            child: Text(
              name,
              style: TextStyle(
                  color: Colors.white, fontSize: ScreenUtil().setSp(30)),
            ),
          ),
          Positioned(
              top: 64,
              left: 123,
              child: Text(
                phone,
                style: TextStyle(
                    color: Colors.white, fontSize: ScreenUtil().setSp(24)),
              )),
          Positioned(
            bottom: 0,
            child: Container(
              width: ScreenUtil().setWidth(750),
              alignment: Alignment.center,
              child: Image.asset(
                'image/advert.png',
                width: ScreenUtil().setWidth(600),
                height: ScreenUtil().setHeight(40),
              ),
            ),
          )
        ],
      ),
    );
  }

  Widget money() {
    return Container(
        color: Colors.white,
        width: ScreenUtil().setWidth(750),
        height: ScreenUtil().setHeight(140),
        child: Row(
          children: <Widget>[
            Expanded(
              child: Container(
                  height: ScreenUtil().setHeight(140),
                  child: InkWell(
                    onTap: () {
                      print('点击了余额');
                    },
                    child: Column(
                      children: <Widget>[
                        Container(
                          margin: EdgeInsets.only(top: 10),
                          child: Text(
                            '0.00',
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(top: 10),
                          child: Text(
                            '余额',
                          ),
                        )
                      ],
                    ),
                  )),
              flex: 1,
            ),
            Expanded(
              child: Container(
                  child: InkWell(
                onTap: () {
                  print('点击了积分');
                },
                child: Column(
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(top: 10),
                      child: Text(
                        '0',
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10),
                      child: Text(
                        '积分',
                      ),
                    )
                  ],
                ),
              )),
              flex: 1,
            ),
            Expanded(
              child: Container(
                  child: InkWell(
                onTap: () {
                  print('点击了钻石');
                },
                child: Column(
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.only(top: 10),
                      child: Text(
                        '钻石',
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 10),
                      child: Text(
                        '盟友',
                      ),
                    )
                  ],
                ),
              )),
              flex: 1,
            )
          ],
        ));
  }

  Widget userorder() {
    return Container(
      width: ScreenUtil().setWidth(750),
      height: ScreenUtil().setHeight(270),
      color: Colors.white,
      child: Column(
        children: <Widget>[
          Container(
              height: ScreenUtil().setHeight(60),
              child: Row(
                children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(left: 10),
                    child: Text(
                      '我的订单',
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(left: 230),
                    child: InkWell(
                      onTap: () {
                        print('点击了订单');
                      },
                      child: Container(
                        child: Row(
                          children: <Widget>[
                            Text('查看全部订单'),
                            Icon(Icons.arrow_forward_ios)
                          ],
                        ),
                      ),
                    ),
                  )
                ],
              )),
          Container(
            padding: EdgeInsets.only(top: 20),
            height: ScreenUtil().setHeight(200),
            child: Row(
              children: <Widget>[
                Expanded(
                  child: InkWell(
                    onTap: () {
                      print('点击了代付款');
                    },
                    child: Column(
                      children: <Widget>[
                        Image.asset('image/payment.png',
                            width: ScreenUtil().setWidth(70),
                            height: ScreenUtil().setHeight(70)),
                        Text('代付款')
                      ],
                    ),
                  ),
                ),
                Expanded(
                  child: InkWell(
                    onTap: () {
                      print('点击了代发货');
                    },
                    child: Column(
                      children: <Widget>[
                        Image.asset('image/stay.png',
                            width: ScreenUtil().setWidth(70),
                            height: ScreenUtil().setHeight(70)),
                        Text('代发货')
                      ],
                    ),
                  ),
                  flex: 1,
                ),
                Expanded(
                  child: InkWell(
                    onTap: () {
                      print('点击了待收货');
                    },
                    child: Column(
                      children: <Widget>[
                        Image.asset('image/payment.png',
                            width: ScreenUtil().setWidth(70),
                            height: ScreenUtil().setHeight(70)),
                        Text('待收货')
                      ],
                    ),
                  ),
                  flex: 1,
                ),
                Expanded(
                  child: InkWell(
                    onTap: () {
                      print('点击了退换/售后');
                    },
                    child: Column(
                      children: <Widget>[
                        Image.asset(
                          'image/sale.png',
                          width: ScreenUtil().setWidth(70),
                          height: ScreenUtil().setHeight(70),
                        ),
                        Text('退换/售后')
                      ],
                    ),
                  ),
                  flex: 1,
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget core(){
    return Container(
      margin: EdgeInsets.only(top: 10),
      child: Column(
        children: <Widget>[
          Container(
            width: ScreenUtil().setWidth(750),
            height: ScreenUtil().setHeight(95),
            color: Colors.white,
            margin: EdgeInsets.only(bottom: 2),
           child: InkWell(
             onTap: (){},
             child: Row(
            children: <Widget>[
              Container(
                child: Text('发票中心'),
                margin: EdgeInsets.only(left: 10,right:310),
              ),
              Icon(Icons.arrow_forward_ios)
            ],
          ),
           )
          ), Container(
            width: ScreenUtil().setWidth(750),
            height: ScreenUtil().setHeight(95),
            color: Colors.white,
            margin: EdgeInsets.only(bottom: 2),
           child: InkWell(
             onTap: (){},
             child: Row(
            children: <Widget>[
              Container(
                child: Text('盟友中心'),
                margin: EdgeInsets.only(left: 10,right:310),
              ),
              Icon(Icons.arrow_forward_ios)
            ],
          ),
           )
          ),
          Container(
            width: ScreenUtil().setWidth(750),
            height: ScreenUtil().setHeight(95),
            color: Colors.white,
            margin: EdgeInsets.only(bottom: 2),
           child: InkWell(
             onTap: (){},
             child: Row(
            children: <Widget>[
              Container(
                child: Text('我的收藏'),
                margin: EdgeInsets.only(left: 10,right:310),
              ),
              Icon(Icons.arrow_forward_ios)
            ],
          ),
           )
          ),
          Container(
            width: ScreenUtil().setWidth(750),
            height: ScreenUtil().setHeight(95),
            color: Colors.white,
            margin: EdgeInsets.only(bottom: 2),
           child: InkWell(
             onTap: (){},
             child: Row(
            children: <Widget>[
              Container(
                child: Text('我的积分'),
                margin: EdgeInsets.only(left: 10,right:310),
              ),
              Icon(Icons.arrow_forward_ios)
            ],
          ),
           )
          ),
          Container(
            width: ScreenUtil().setWidth(750),
            height: ScreenUtil().setHeight(95),
            color: Colors.white,
            margin: EdgeInsets.only(bottom: 2),
           child: InkWell(
             onTap: (){},
             child: Row(
            children: <Widget>[
              Container(
                child: Text('我的地址'),
                margin: EdgeInsets.only(left: 10,right:310),
              ),
              Icon(Icons.arrow_forward_ios)
            ],
          ),
           )
          ),
          Container(
            width: ScreenUtil().setWidth(750),
            height: ScreenUtil().setHeight(95),
            color: Colors.white,
            margin: EdgeInsets.only(bottom: 2),
           child: InkWell(
             onTap: (){},
             child: Row(
            children: <Widget>[
              Container(
                child: Text('专属客服'),
                margin: EdgeInsets.only(left: 10,right:310),
              ),
              Icon(Icons.arrow_forward_ios)
            ],
          ),
           )
          ),
        ],
      ),
    );
  }
}
